//
//  NSURL+YTX.m
//  p4
//
//  Created by yang xincheng on 15/2/5.
//  Copyright (c) 2015年 com.baidao. All rights reserved.
//

#import "NSURL+YTX.h"
//#import "EFSUserManager.h"
//#import "EFSServiceManager.h"
//#import "EFSNFXGTradeManager.h"
#import "YSAppInfo.h"
@implementation NSURL (YTX)

- (NSURL *)URLByAppendingEnvAndAgent
{

    //env
    NSURL *url = [self copy];
//    NSString *env = [EFSServiceManager sharedServiceManager].env;
//    env = [env isEqualToString:@"production"] ? @"production" : @"development";
//    @TODO("强制生成环境");
    NSString *env = @"production";
    url = [url URLByAppendingQueryDictionary:@{@"env": env}];
    //agent
    NSString *agent = [YSAppInfo marketId];
    if (agent) {
        url = [url URLByAppendingQueryDictionary:@{@"agent": agent}];
    }
    return url;
}

- (NSURL *)URLByAppendingAgent
{
    
    NSURL *url = [self copy];
    //agent
//    NSString *agent = [EFSServiceManager sharedServiceManager].agent;
//    if (agent) {
//        url = [url URLByAppendingQueryDictionary:@{@"agent": agent}];
//    }
    return url;
}

- (NSURL *)URLByAppendingEnvAgentAndToken
{
    //token
    NSURL *url = [self URLByAppendingEnvAndAgent];
//    NSString *token = [EFSUserManager sharedManager].currentUser.token;
//    if (token) {
//        url = [url URLByAppendingQueryDictionary:@{@"token": token}];
//    }
    return url;
}

- (NSURL *)URLByAppendingToken
{
    NSURL *url = [self copy];

//    NSString *token = [EFSUserManager sharedManager].currentUser.token;
//    if (token) {
//        url = [url URLByAppendingQueryDictionary:@{@"token": token}];
//    }
    return url;
}

- (NSURL *)URLByExtNO{
    NSURL *url = [self copy];
    
//    NSString *extNo = [EFSUserManager sharedManager].currentUser.brokerCode;
//    if (extNo) {
//        url = [url URLByAppendingQueryDictionary:@{@"ext_no": extNo}];
//    }
    return url;
}

- (NSURL *)URLByAppendingAllInfo
{
    NSURL *url = [self copy];
    
//    NSString *token = [EFSUserManager sharedManager].currentUser.token;
//    NSString *username =[EFSUserManager sharedManager].currentUser.username;
//    //TODO 要考虑多账号的情况
//    NSString *tradeAccount = [EFSUserManager sharedManager].currentTradeAccount.account;
//    NSString *agent = [EFSServiceManager sharedServiceManager].agent;
//    url = [url URLByAppendingQueryDictionary:@{@"token": objectOrEmptyStr(token),
//                                               @"username":objectOrEmptyStr(username),
//                                               @"tradeaccount":objectOrEmptyStr(tradeAccount),
//                                               @"agent": objectOrEmptyStr(agent),
//                                               @"env":@"production"}];

    return url;
}

- (NSURL *)URLByAppendingRoomInfo
{
    NSURL *url = [self copy];
    
//    NSString *token = [EFSUserManager sharedManager].currentUser.token;
    return url;
}

@end
